import React from 'react';
import PropTypes from 'proptypes';
import style from './index.css';
import { hashHistory } from 'react-router';

const Article = props => {
    const { title, content, tags, uuid, create_time} = props;
    return (
        <div className={style.container} onClick={() => hashHistory.push(`/thread/${uuid}`)}>
            <article>
                <header>{ title }</header>
                <span>{ create_time }</span>
                <section>{content}</section>
            </article>
            <section>
                {
                    tags.map((tag, index) => <span key={index}> { tag.tag }</span>)
                }
            </section>
        </div>
    )
}

Article.propTypes = {
    uuid: PropTypes.string,
    title: PropTypes.string,
    content: PropTypes.string,
    create_time: PropTypes.string,
    tags: PropTypes.array
}

export default Article;
